package com.av.acciones;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.av.exceptions.AvException;
import com.av.rmi.Parametro;

public abstract class BaseAccion {

	private static ApplicationContext ctx;

	public static ApplicationContext getContext() {
		if (ctx == null) {
			ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		}

		return ctx;
	}// getContext

	public static BaseAccion getAccion(String accion) {
		if (accion != null && accion.trim().length() > 0) {
			return (BaseAccion) getContext().getBean(accion);
		}
		return null;
	}// getAccion

	public static Object getBean(String bean) {
		return getContext().getBean(bean);
	}// getBean

	public abstract Parametro ejecutar(Parametro parametro) throws AvException;
}// BaseAccion
